<?php
include_once("../includes/tag_inc.php");
//===============================================
if(!isset($_POST['is_rec']))
	$_POST['is_rec']='0';
if(!isset($_POST['statu']))
	$_POST['statu']='0';
$date=date("Y-m-d H:i:s");$pn=NULL;
if(isset($_POST['action'])&&$_POST['action']=="edit")
{
	$_POST['stime']=strtotime($_POST['stime']);
	$_POST['etime']=strtotime($_POST['etime']);
	$sql="update ".EXHIBIT." SET
	stime='$_POST[stime]',etime='$_POST[etime]',city='$_POST[city]',addr='$_POST[addr]',
	statu='$_POST[statu]',title='$_POST[title]',country='$_POST[country]',con='$_POST[con]',
	cat='$_POST[cat]',organizers='$_POST[organizers]',contractors='$_POST[contractors]',contact='$_POST[contact]',tel='$_POST[tel]',showroom='$_POST[showroom]',pic='$_POST[pic]'
	WHERE id='$_POST[id]'";
	$re=$db->query($sql);
	edit_tags($_POST['tag'],4,$_POST['id']);
	if($re)
	{
		unset($_GET['id']);unset($_GET['s']);
		$getstr=implode('&',convert($_GET));
		admin_msg("module.php?m=exhibition&s=exhibitlist.php&$getstr",'操作成功');
	}
}
//=================================================
if(!empty($_POST['action'])&&$_POST['action']=="submit")
{
	$_POST['stime']=strtotime($_POST['stime']);
	$_POST['etime']=strtotime($_POST['etime']);
	$sql="INSERT ".EXHIBIT." (stime,etime,country,city,addr,statu,title,con,addTime,cat,organizers,contractors,contact,tel,showroom,pic)
	VALUES
   ('$_POST[stime]','$_POST[etime]','$_POST[country]','$_POST[city]','$_POST[addr]','$_POST[statu]',
   '$_POST[title]','$_POST[con]','$date','$_POST[cat]','$_POST[organizers]','$_POST[contractors]','$_POST[contact]','$_POST[tel]','$_POST[showroom]','$_POST[pic]')";
	$re=$db->query($sql);
	$id=$db->lastid();
	add_tags($_POST['tag'],4,$id);
	if($re)
		admin_msg("module.php?m=exhibition&s=exhibitlist.php",'操作成功');
}
if(isset($_GET['id']))
{
	$sql="select * from ".EXHIBIT." where id='$_GET[id]'";
	$db->query($sql);
	$de=$db->fetchRow();
	$de['tag']=get_tags($_GET['id'],4);
}
?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<HEAD>
<TITLE><?php echo lang_show('admin_system');?></TITLE>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<script language="javascript" src="../script/Calendar.js"></script>
<script type="text/javascript" src="main.js"></script>
<script>
closeimg='<?php echo $config['weburl'];?>/image/default/icon_close.gif';
weburl='<?php echo $config['weburl'];?>';
</script>
<script src="../script/my_lightbox.js" language="javascript"></script>
<script type="text/javascript" src="../script/prototype.js"></script>
<link href="main.css" rel="stylesheet" type="text/css" />
</HEAD>
<body>
<div class="bigbox">
	<div class="bigboxhead"><?php echo lang_show('news_post');?></div>
	<div class="bigboxbody">
    <form method="post" action="" enctype="multipart/form-data">
    <table width="100%" border="0"  cellpadding="0" cellspacing="0">
	    <tr>
          <td><?php echo lang_show('state');?></td>
	      <td colspan="3">
		   <select class="select" name="country" id="country">
		  	<?php
			$sql="select * from ".COUNTRY." where 1 order by nums asc,ename asc";
			$db->query($sql);
			$country=$db->getRows();
			foreach($country as $v)
			{
			?>
		   <option value="<?php echo $v['ename'];?>" <?php if(isset($de['country'])&&$de['country']==$v['ename']) echo "selected";?>><?php echo $v['ename'];?> </option>
		  <?php
			}
			?>
            </select>			</td>
        </tr>
        <tr>
				<?php
				$sql="select * from ".SHOWROOM;
				$db->query($sql);
				$ex=$db->getRows();
				?>
                  <td><?php echo lang_show('exroom');?></td>
			      <td colspan="3">
				  <select class="select"  name="showroom" id="showroom">
				  <option value=""><?php echo lang_show('noexroom');?></option>
				  <?php
				  foreach($ex as $v)
				  {
				  ?>
			        <option value="<?php echo $v['show_room_name'];?>"<?php if(isset($de['showroom'])&&$de['showroom']==$v['show_room_name']) echo 'selected';?>><?php echo $v['show_room_name'];?></option>
					<?php
				  }
					?>
			        </select>
                    <a href="module.php?m=exhibition&s=edit_show_room.php"><?php echo lang_show('addroom');?></a>
					</td>
        		</tr>
		            <tr> 
            <td class="body_left"> <?php echo lang_show('show_title');?></td>
            <td  colspan="3"><input class="text" name="title" type="text" value="<?php if(isset($de['title'])){echo $de['title'];}?>"  maxlength="100"></td>
          </tr>
        <tr> 
		          <tr>
            <td> <?php echo lang_show('tag_con');?></td>
            <td colspan="3">
            <input name="tag" class="text" type="text" id="tag" value="<?php if(isset($de['tag'])){echo $de['tag'];}?>" maxlength="40">多个关键词用英文,号分隔。</td>
          </tr>
		  <tr> 
	      <td width="10%"  > <?php echo lang_show('show_time');?></td>
          <td  colspan="3">
			<script language="javascript">
			var cdr = new Calendar("cdr");
			document.write(cdr);
			cdr.showMoreDay = true;
			</script>
		  <input readonly name="stime" type="text" id="stime" class="ltext" value="<?php if(isset($de['stime'])){echo date("Y-m-d",$de['stime']);}?>" onFocus="cdr.show(this);"> -- 
          <input readonly onFocus="cdr.show(this);" name="etime" type="text" id="etime" class="rtext" value="<?php if(isset($de['etime'])){echo date("Y-m-d",$de['etime']);}?>"></td>
        </tr>
	      <tr><td width="10%"  > <?php echo lang_show('city');?></td>
          <td width="31%" ><input name="city" type="text" id="city" value="<?php if(isset($de['city'])){echo $de['city'];}?>" class="text" maxlength="40"></td>
          <td width="7%" align="right"><?php echo lang_show('address');?></td>
          <td width="52%" ><input name="addr" type="text" id="addr" value="<?php if(isset($de['addr'])){echo $de['addr'];}?>" class="text"></td>
        </tr>
			    <tr> 
	      <td width="10%" ><?php echo lang_show('org');?></td>
          <td width="31%" ><input name="organizers" type="text" id="organizers" class="text" maxlength="100" value="<?php if(isset($de['organizers'])){echo $de['organizers'];}?>"></td>
          <td width="7%" align="right"><?php echo lang_show('cnor');?></td>
          <td width="52%"><input name="contractors" type="text" id="contractors" class="text" maxlength="100" value="<?php if(isset($de['contractors'])){echo $de['contractors'];}?>"></td>
	    </tr>
		<tr>
		  <td><?php echo lang_show('contact');?></td>
		  <td><input name="contact" type="text" id="contact" class="text" maxlength="50" value="<?php if(isset($de['contact'])){echo $de['contact'];}?>"></td>
		  <td align="right"><?php echo lang_show('tel');?></td>
		  <td><input name="tel" type="text" id="tel" class="text" maxlength="20" value="<?php if(isset($de['tel'])){echo $de['tel'];}?>"></td>
	    </tr>
          	<tr>
			  <td><?php echo lang_show('excat');?></td>
			  <td colspan="3">
			  <textarea style="width:99%" name="cat" rows="2"><?php if(isset($de['cat'])){echo $de['cat'];}?></textarea>
			  </td>
        	</tr>
          <tr> 
            <td><?php echo lang_show('show_content');?></td>
            <td colspan="3"> 
			<?php
			$BasePath = "../lib/fckeditor/";
			include($BasePath."fckeditor.php");	
			$fck_en = new FCKeditor('con') ;
			$fck_en->BasePath    = $BasePath ;
			$fck_en->ToolbarSet  = 'Default' ;
			if($config['language']=='cn')
				$fck_en->Config['DefaultLanguage']='zh-cn';
			else
				$fck_en->Config['DefaultLanguage']='en';
			$fck_en->Width='100%';
			$fck_en->Height=500;
			$fck_en->Config['ToolbarStartExpanded'] = true;
			$fck_en->Value = stripslashes($de['con']);
			echo $fck_en->CreateHtml();
			?>
			</td>
          </tr>
		   <tr>
		  <td><?php echo lang_show('expic');?></td>
		  <td colspan="3">
			 <input name="pic" type="text" id="pic" value="<?php echo $de['pic'];?>" class="text">
			 [<a href="javascript:uploadfile('上传LOGO','pic',300,300)">上传</a>] 
			 [<a href="javascript:preview('pic');">预览</a>]
			 [<a href="javascript:delet_pic('pic');">删除</a>]
		  </td>
        </tr>
	   <tr>
		  <td><?php echo lang_show('is_post');?></td>
		  <td colspan="3">
		  <select class="select" name="statu">
			  <option <?php if($de['statu']==0) echo 'selected="selected"';?> value="0">关闭</option>
			  <option <?php if($de['statu']==1) echo 'selected="selected"';?> value="1">展示</option>
			  <option <?php if($de['statu']==2) echo 'selected="selected"';?> value="2">推荐1</option>
			  <option <?php if($de['statu']==3) echo 'selected="selected"';?> value="3">推荐2</option>
		  </select>
		  </td>
		</tr>
          <tr> 
            <td>&nbsp;</td>
            <td colspan="3"> 
              <input class="btn" type="submit" name="cc" value="<?php echo lang_show('submit');?>">
              <input name="action" type="hidden" id="action" value="<?php if(isset($_GET['id'])) echo "edit";else echo "submit"; ?>">
            <input name="id" type="hidden" id="id" value="<?php if (isset($de['id'])) echo $de['id'];?>"></td>
          </tr>
      </table>
      </form>  
    </div>
</div>
</body>
</html>